<style>
.companytable tr td{
    height: 80px;
    border-top: 1px solid #e8ecf0;
    border-right: 1px solid #e8ecf0;
    padding-left: 20px;
}
.companytable{
    width:100%;
    border-left: 1px solid #e8ecf0;
    border-bottom: 1px solid #e8ecf0;
}
.focusbtn:hover .btn1 {
  background-color: #3c7eee;
  color: #ffffff;
}
</style>
<template>
    <div style="padding-top:85px;"> 
    <div style="width:80%;display:flex;justify-content:center;margin-left: 10%;">
      <div style="display:flex;flex-direction: column;width:100%;">
        <!-- 内容-我的主页 -->
        <div class="personal-strategy" style="width:100%;display:flex;justify-content:space-between;">
              <!-- 标题 -->
            <div id="personal-strategy-title" style="display:flex;justify-content: flex-start;margin-top:20px;">
                <h4 style="color: #333;font-size:20px;font-weight: 700;line-height: 22px;margin-left:20px;">添加公司</h4>
            </div>
            <div class="focusbtn" style="margin-left:20px;display:flex;flex-direction:row;height: 39px;">
                <div style="background-color: #3c7eee;color: #ffffff;cursor: pointer;padding: 6px 24px;border-radius: 4px;margin-right:10px;" @click="edit()">提交</div>
                <div style="background-color: #3c7eee;color: #ffffff;cursor: pointer;padding: 6px 24px;border-radius: 4px;" @click="back()">返回</div>
            </div>
        </div>
        <div>
            <table class="companytable">
                <tr>
                    <td width="10%" style="text-align: center;">公司简称</td>
                    <td><el-input v-model="companyName" placeholder="请输入内容"></el-input></td>
                    <td style="text-align: center;">股票代码</td>
                    <td>{{companydetail.stockNumber}}</td>
                    <td style="text-align: center;">成立日期</td>
                    <td>{{companydetail.established}}</td>
                </tr>
                <tr>
                    <td style="text-align: center;">公司全称</td>
                    <td colspan="2"><el-input v-model="companyFullName" placeholder="请输入内容"></el-input></td>
                    <td style="text-align: center;">公司英文名称</td>
                    <td colspan="2"><el-input v-model="companyEnglishName" placeholder="请输入内容"></el-input></td>
                </tr>
                <tr>
                    <td style="text-align: center;">所属行业</td>
                    <td colspan="2">{{companydetail.industry}}</td>
                    <td style="text-align: center;">所属概念</td>
                    <td colspan="2">{{companydetail.ownConcept}}</td>
                </tr>
                <tr>
                    <td style="text-align: center;">注册地址</td>
                    <td colspan="2">{{companydetail.registereAddress}}</td>
                    <td style="text-align: center;">所得税率</td>
                    <td colspan="2">{{companydetail.incomeTaxRate}}</td>
                </tr>
                <tr>
                    <td>上市交易所</td>
                    <td>{{companydetail.listedExchanges}}</td>
                    <td>证券类型</td>
                    <td>{{companydetail.incosecuritiesTypemeTaxRate}}</td>
                    <td>上市日期</td>
                    <td>{{companydetail.listingDate}}</td>
                </tr>
                <tr>
                    <td>流通股本</td>
                    <td>{{companydetail.circulatingCapitalStock}}</td>
                    <td>总股本</td>
                    <td>{{companydetail.totalShareCapital}}</td>
                    <td>发行价</td>
                    <td>{{companydetail.issuancePrice}}</td>
                </tr>
                <tr>
                    <td>联系电话</td>
                    <td><el-input v-model="contactPhone" placeholder="请输入内容"></el-input></td>
                    <td>公司传真</td>
                    <td><el-input v-model="companyFax" placeholder="请输入内容"></el-input></td>
                    <td>公司邮箱</td>
                    <td><el-input v-model="email" placeholder="请输入内容"></el-input></td>
                </tr>
                <tr>
                    <td>公司网址</td>
                    <td><el-input v-model="companyWebsite" placeholder="请输入内容"></el-input></td>
                    <td>联系人</td>
                    <td><el-input v-model="contact" placeholder="请输入内容"></el-input></td>
                    <td>经营范围</td>
                    <td><el-input v-model="businessScope" placeholder="请输入内容"></el-input></td>
                </tr>
                <tr>
                    <td>公司简介</td>
                    <td colspan="5"><el-input
                    v-model="companyProfile"
                        type="textarea"
                        :autosize="{ minRows: 2, maxRows: 10}"
                        placeholder="请输入内容">
                    </el-input></td>
                </tr>
            </table>
        </div>
      </div>
    </div>
    </div>
</template>
<script>
export default {
    data(){
        return{
            companydetail:'',
            companyid:'',
            companyName:'',
            companyFullName:'',
            companyEnglishName:'',
            contactPhone:'',
            companyFax:'',
            email:'',
            companyWebsite:'',
            contact:'',
            businessScope:'',
            companyProfile:'',
            sessionToken:''
        }
    },
    mounted(){
        this.companyid = localStorage.getItem('companyid')
        this.sessionToken = localStorage.getItem('SessionToken')
        this.getcompanydetail()
    },
    methods:{
        back(){
            this.$router.push('/company')
        },
        getcompanydetail(){
            this.$http.get('stock/getStockCompanyById?id='+this.companyid+'').then((resp) => {
                if (resp.data.status === 200) {
                    console.log(resp.data)
                    this.companydetail=resp.data.data
                    this.companyName=this.companydetail.companyName
                    this.companyFullName=this.companydetail.companyFullName
                    this.companyEnglishName=this.companydetail.companyEnglishName
                    this.contactPhone=this.companydetail.contactPhone
                    this.companyFax=this.companydetail.companyFax
                    this.email=this.companydetail.email
                    this.companyWebsite=this.companydetail.companyWebsite
                    this.contact=this.companydetail.contact
                    this.businessScope=this.companydetail.businessScope
                    this.companyProfile=this.companydetail.companyProfile
                }else if(resp.data.status === 499){
                    this.$message.error('当前用户没有该权限！')
                }else {
                    console.log('获取公司信息失败')
                }
            })
        },
        edit(){
            let param={
                id: this.companyid,
                companyName:this.companyName,
                companyFullName:this.companyFullName,
                companyEnglishName:this.companyEnglishName,
                usedName:this.companydetail.usedName,
                legalRepresentative:this.companydetail.legalRepresentative,
                consultingServiceAgency:this.companydetail.consultingServiceAgency,
                accountingFirm:this.companydetail.accountingFirm,
                securitiesAffairsRepresentative:this.companydetail.securitiesAffairsRepresentative,
                latestPriceEarningsRatio:this.companydetail.latestPriceEarningsRatio,
                zipCode:this.companydetail.zipCode,
                contactPhone:this.contactPhone,
                companyFax:this.companyFax,
                email:this.email,
                companyWebsite:this.companyWebsite,
                contact:this.contact,
                businessScope:this.businessScope,
                companyProfile:this.companyProfile
            }
            param = JSON.stringify(param)
            console.log(param)
            this.$http.post('stock/updateStockCompany?sessionToken='+this.sessionToken+'',param,{headers:{'Content-Type':'application/json'}}).then((resp) => {
                if (resp.data.status === 200) {
                    this.$message.success('修改公司信息成功')
                    
                }else if(resp.data.status === 499){
                    this.$message.error('当前用户没有该权限！')
                }else {
                    this.$message.error('修改公司信息失败')
                }
            })

        }
    }
}
</script>